home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / pdcurs21.zip / PORTABLE.ZIP / MVWSCANW.C < prev    next >
Text File  |  1992-11-21  |  3KB  |  82 lines

  1. #include <stdarg.h>
  2. #include <string.h>
  3. #define        CURSES_LIBRARY  1
  4. #include <curses.h>
  5. #undef mvwscanw
  6.  
  7. #ifndef        NDEBUG
  8. char *rcsid_mvwscanw = "$Header: c:/curses/portable/RCS/mvwscanw.c%v 2.0 1992/11/15 03:29:02 MH Rel $";
  9. #endif
  10.  
  11.  
  12.  
  13. /*man-start*********************************************************************
  14.  
  15.   mvwscanw()   - read formatted from window
  16.  
  17.   X/Open Description:
  18.        These routines correspond to scanf.  The function scanw reads
  19.        input from the default window.  The function wscanw reads
  20.        input from the specified window.  The function mvscanw moves
  21.        the cursor to the specified position and then reads input from
  22.        the default window.  The function mvwscanw moves the cursor to
  23.        the specified position and then reads input from the specified
  24.        window.
  25.  
  26.        For all the functions, the routine wgetstr is called to get a
  27.        string from the window, and the resulting line is used as
  28.        input for the scan.  All character interpretation is carried
  29.        out according to the scanf function rules.
  30.  
  31.   PDCurses Description:
  32.        The old Bjorn Larssen code for the 68K platform has been removed
  33.        from this module.
  34.  
  35.   X/Open Return Value:
  36.        Upon successful completion, the scanw, mvscanw, mvwscanw and
  37.        wscanw functions return the number of items successfully
  38.        matched.  On end-of-file, they return EOF.  Otherwise they
  39.        return ERR.
  40.  
  41.   PDCurses Errors:
  42.        No errors.
  43.  
  44.   Portability:
  45.        PDCurses        int mvwscanw(WINDOW* win, int y, int x, char *fmt, ...);
  46.        X/Open Dec '88  int mvwscanw(WINDOW* win, int y, int x, char *fmt, ...);
  47.        BSD Curses      int mvwscanw(WINDOW* win, int y, int x, char *fmt, ...);
  48.        SYS V Curses    int mvwscanw(WINDOW* win, int y, int x, char *fmt, ...);
  49.  
  50. **man-end**********************************************************************/
  51.  
  52. int    mvwscanw(WINDOW * win, int y, int x, char *fmt,...)
  53. {
  54.        va_list args;
  55.        int     retval = ERR;
  56.  
  57. #if    !defined (HC)
  58.        if (win == (WINDOW *)NULL)
  59.                return( retval );
  60.  
  61.        if (wmove(win, y, x) == ERR)
  62.                return( retval );
  63.  
  64.        wrefresh(win);          /* set cursor position */
  65.  
  66.        /*
  67.         * get string
  68.         */
  69.        c_printscanbuf[0] = '\0';  /* reset to empty string */
  70.        if (wgetstr(win, c_printscanbuf) == ERR)
  71.                return( retval );
  72.        va_start(args, fmt);
  73. #ifdef NO_VSSCANF
  74.        retval = PDC_vsscanf(c_printscanbuf, fmt, args);
  75. #else
  76.        retval = vsscanf(c_printscanbuf, fmt, args);
  77. #endif
  78.        va_end(args);
  79. #endif
  80.        return( retval );
  81. }
  82.